<form id="myform" class="layui-form layui-form-pane" action="" style="margin: 5px">
    <!--<div class="layui-form-item">-->
        <!--<label class="layui-form-label">版本号</label>-->
        <!--<div class="layui-input-block">-->
            <!--<select id="versionid" name="versionid" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input"/>-->
        <!--</div>-->
    <!--</div>-->
    <div class="layui-form-item">
        <label class="layui-form-label">编号</label>
        <div class="layui-input-block" >
            <input id="number" lay-filter="test1" type="text" name="number" required lay-verify="required" placeholder="请输入唯一标识名称（英文）" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input id="title" type="text" name="title" required  lay-verify="required" placeholder="请输入唯一标识名称（英文）" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">标题描述</label>
        <div class="layui-input-block">
            <input id="titledescription" type="text" name="titledescription" required  lay-verify="required" placeholder="请输入唯一标识名称（英文）" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">回答</label>
        <div class="layui-input-block">
            <input id="answer" type="text" name="answer" required  lay-verify="required" placeholder="请输入唯一标识名称（英文）" autocomplete="off" class="layui-input">
        </div>
    </div>
    <!--<div class="layui-form-item layui-form-text">
        <label class="layui-form-label">请填写描述</label>
        <div class="layui-input-block">
            <textarea type="text" name="versionremark" required  lay-verify="required"  placeholder="请输入内容" class="layui-textarea"></textarea>
        </div>
    </div>-->

    <!--<div class="layui-form-item">-->
        <!--<label class="layui-form-label">菜单级别</label>-->
        <!--<div class="layui-input-block"  id="menu_level">-->
            <!--<select name="menu_level" lay-verify="required" lay-filter = "menu_level">-->
                <!--<option value=""></option>-->
                <!--<option value="1">一级菜单</option>-->
                <!--<option value="2">二级菜单</option>-->
            <!--</select>-->
        <!--</div>-->
    <!--</div>-->
    <!--<div class="layui-form-item">-->
        <!--<label class="layui-form-label">父级菜单</label>-->
        <!--<div class="layui-input-block" id="parent_menu">-->
            <!--<select name="parent_menu" lay-verify="required" lay-filter = "parent_menu">-->
                <!--<option value=""></option>-->
                <!--<option value="1">菜单1</option>-->
                <!--<option value="2">菜单2</option>-->
            <!--</select>-->
        <!--</div>-->
    <!--</div>-->
    <!--<div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <select name="versionstate" lay-verify="required" lay-filter="parent_menu" id="parent_menu">
                <option value=""></option>
                <option value="1" selected>启用</option>
                <option value="2">不启用</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">操作员</label>
        <div class="layui-input-block">
            <input type="text" name="operator" required value="cwjk" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
        </div>
    </div>-->
    <!--<div class="layui-form-item">-->
        <!--<label class="layui-form-label">添加时间</label>-->
        <!--<div class="layui-input-block">-->
            <!--<input type="text" name="makedate" required  lay-verify="required" placeholder="请输入唯一标识名称（英文）" autocomplete="off" class="layui-input">-->
        <!--</div>-->
    <!--</div>-->
    <!--<div class="layui-form-item">-->
        <!--<label class="layui-form-label">修改时间</label>-->
        <!--<div class="layui-input-block">-->
            <!--<input type="text" name="operator" required  lay-verify="required" placeholder="请输入唯一标识名称（英文）" autocomplete="off" class="layui-input">-->
        <!--</div>-->
    <!--</div>-->
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script>
    layui.use(['jquery','baajax','form'], function(){
        var form = layui.form;
        var ajax=layui.baajax;
        var $=layui.jquery;
        // $.ajax({
        //     type: "get",
        //     /*data:{
        //         codetype : "resstate"
        //     },*/
        //     url: "/firulesversion/list",
        //     dataType: "json",
        //     cache: 0,
        //     success: function (data) {
        //         var option='';
        //         $.each(data.data,function(index,data1){
        //             option="<option value='"+data1.id+"'>"+data1.versionnumber+"-"+data1.versionname+"</option>";
        //             $("#versionid").append(option);
        //             form.render('select');
        //         });
        //     },
        //     error: function () {
        //         //errorFunc();
        //     }
        // });
        //监听提交
        form.on('submit(formDemo)', function(data){
            layer.msg(JSON.stringify(data.field));
            $.ajax({
                type: "POST",
                url: "/questionanswer",
                dataType: "json",
                data: data.field,
                cache: true,
                async: false,
                success: function (data) {
                    if(data.code=='200'){
                        //layer.msg('添加成功');
                        layer.confirm('添加成功,是否继续添加?', {icon: 3, title:'提示'}, function(index){
                            //form.render(null, 'test1');
                            // $("#myform").get(0).reset();
                            layer.close(index);
                        },function(index){
                            //do something
                            //alert(index);
                            //table.refresh();
                            layer.closeAll();
                        });
                    }
                    // var ret = data;
                    // succFunc(ret, paras);
                },
                error: function () {
                    layer.msg('失败');
                    // errorFunc();
                }
            })
            return false;
        });
    });
</script>